package cn.zakrov.sbs006.controller;

import cn.zakrov.sbs006.entity.JsonResult;
import cn.zakrov.sbs006.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/swagger")
@Api(value = "Swagger online document")
public class TestController {
    @GetMapping("/get/{id}")
    @ApiOperation(value = "Get user info by id")
    public JsonResult<User> getUserInfo(@PathVariable @ApiParam(value = "user id") Long id) {
        User user = new User(id, "Zakrov", "123456");
        return new JsonResult(user);
    }

    @PostMapping("/insert")
    @ApiOperation(value = "Insert user")
    public JsonResult<Void> insertUser(@RequestBody @ApiParam(value = "user info") User user) {
        return new JsonResult<>("0", user.getId().toString());
    }
}
